<template>
  <div class="card">

    <div class="imgbox"  v-if="total==0">
      <img src="@/assets/images/nopublic.png" alt="">
      <span>暂无内容</span>
    </div>
    <div class="item"
         v-for="item in list"
         :key="item.id"
         @click="toDetail(item.id)">
      <div class="left">
        <div class="totop"
             v-if="item.top">置顶</div>
        <div class="title">{{item.title}}</div>

      </div>
      <div class="right">
        {{item.createdTime}}
      </div>
    </div>
    <div class="pag">
      <el-pagination background
                     v-if="total!=0"
                     layout="prev, pager, next"
                     :page-size='10'
                     :total="total"
                     @current-change="currentChange">
      </el-pagination>
    </div>

  </div>

</template>

<script>
export default {
  name: 'newsList',
  components: {},
  props: ['list', 'total'],
  data() {
    return {}
  },

  methods: {
    toDetail(id) {
      // this.$router.push({ name: 'newsDetail', query: { id: id } })
      let { href } = this.$router.resolve({
        name: 'newsSingle',
        query: { id: id },
      })
      window.open(href, '_blank')
    },
    currentChange(v) {
      this.$emit('currentChange', v)
    },
  },

  computed: {},

  mounted() {},
}
</script>
<style lang='scss' scoped>
.imgbox{
  width: 100%;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  position: relative;
  span{
    position: absolute;
    bottom:180px;
    font-size: 18px;
    color: #0F47B8;
    letter-spacing: 1px;
  }
}
.card {
  background: #ffffff;
  padding: 0 30px 30px 30px;
  height: 500px;
  box-sizing: border-box;
  .item {
    height: 50px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .left {
      display: flex;
      align-items: center;
    }
    .totop {
      width: 50px;
      height: 26px;
      text-align: center;
      line-height: 26px;
      background: #3772ff;
      border-radius: 4px;
      color: white;
      margin-right: 10px;
    }
    .title {
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #333333;
      // margin-bottom: 12px;
    }
    .subtitle {
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #666666;
    }
    .right {
      flex-shrink: 0;
      font-size: 12px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #999999;
    }
    .title,
    .subtitle {
      width: 700px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      -o-text-overflow: ellipsis;
    }
    &:hover {
      cursor: pointer;
    }
  }
  .pag {
    text-align: center;
    padding-top: 48px;
  }
}
</style>